﻿using StoreProject.DAL.SettingDAL;
using StoreProject.Entity.SettingEntity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StoreProject.BLL.SettingBLL
{
    public class WorkingProcedureNameBLL
    {
        private readonly WorkingProcedureNameDAL _dal = new WorkingProcedureNameDAL();

        public bool Insert(WorkingProcedureNameEntity model)
        {
            bool res = false;
            int? result = _dal.Insert(model);
            if (result != null)
                res = (int)result > 0;
            return res;
        }

        public bool InsertOrUpdate(WorkingProcedureNameEntity model)
        {
            bool res = false;
            int? result = 0;
            if (_dal.IsExists(model.Id))
            {
                _dal.Update(model);
            }
            else
            {
                _dal.Insert(model);
            }
            if (result != null)
                res = (int)result > 0;
            return res;
        }

        public bool Update(WorkingProcedureNameEntity model)
        {
            bool res = false;
            int result = _dal.Update(model);
            res = (int)result > 0;
            return res;
        }

        public bool Delete(string id)
        {
            bool res = false;
            int result = _dal.Delete(id);
            res = (int)result > 0;
            return res;
        }

        public bool Delete(WorkingProcedureNameEntity model)
        {
            bool res = false;
            int result = _dal.Delete(model);
            res = (int)result > 0;
            return res;
        }

        public WorkingProcedureNameEntity Get(string id)
        {
            return _dal.Get(id);
        }

        public IEnumerable<WorkingProcedureNameEntity> GetList()
        {
            return _dal.GetList();
        }

        public IEnumerable<WorkingProcedureNameEntity> GetListEx()
        {
            return _dal.GetListEx();
        }

        public IEnumerable<WorkingProcedureNameEntity> GetListByWhere(string sql)
        {
            return _dal.GetListByWhere(string.Format("CustomerName like  '{0}'", sql));
        }
        public int DeleteAll()
        {
            return _dal.DeleteAll();
        }
    }
}
